﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MISAPP.Classify.DataAccess;
using System.Data;

namespace MISAPP.Classify.Service
{
    public class Service_Q1 : Service_Matrix
    {
        protected DA_Q1 da = null;
        protected DA_Q1 DA
        {
            get
            {
                if (da == null)
                {
                    da = new DA_Q1();
                }
                return da;
            }
        }

        public bool Insert(List<Squared> p_squared, string p_user)
        {
            bool ok = false;
            try
            {
                foreach (Squared sq in p_squared)
                {
                    if (false == DA.Insert(sq.MISGroup, sq.Amount
                        , p_user, sq.RowPos, sq.Sheet))
                    {
                        throw new Exception("新增失敗");
                        ok = false;
                    }
                }
                ok = true;
            }
            catch (Exception ex)
            {
                throw new Exception("新增失敗");
                ok = false;
            }
            return ok;
        }

        public DataTable GetDataBySheet(string p_sheet)
        {
            return DA.GetDataBySheet(p_sheet);
        }

        public List<Squared> GetBonusCell(string p_level)
        {
            return GetParameterValue(DA, new object[] { p_level });
        }
    }
}
